home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
awe2-0_1.lha
/
awe2-0.1
/
Src
/
RCS
/
Histogram.cc,v
< prev
next >
Wrap
Text File
|
1989-05-04
|
3KB
|
176 lines
head 3.3;
branch ;
access ;
symbols ;
locks grunwald:3.3; strict;
comment @@;
3.3
date 89.05.04.15.00.03; author grunwald; state Exp;
branches ;
next 3.2;
3.2
date 89.02.20.15.35.01; author grunwald; state Exp;
branches ;
next 3.1;
3.1
date 88.12.20.13.48.52; author grunwald; state Exp;
branches ;
next 1.2;
1.2
date 88.10.30.13.03.11; author grunwald; state Exp;
branches ;
next 1.1;
1.1
date 88.09.18.16.42.25; author grunwald; state Exp;
branches ;
next ;
desc
@@
3.3
log
@ Before switching to Libg++ version
@
text
@// This may look like C code, but it is really -*- C++ -*-
//
// Copyright (C) 1988 University of Illinois, Urbana, Illinois
//
// written by Dirk Grunwald (grunwald@@cs.uiuc.edu)
//
#include "Histogram.h"
#include <math.h>
const int HistogramMinimum = -2;
const int HistogramMaximum = -1;
Histogram::Histogram(double low, double high, double width)
{
if (high < low) {
double t = high;
high = low;
low = t;
}
if (width == -1) {
width = (high - low) / 10;
}
howManyBuckets = int((high - low) / width) + 2;
bucketCount = new int[howManyBuckets];
bucketLimit = new double[howManyBuckets];
double lim = low;
for (int i = 0; i < howManyBuckets; i++) {
bucketCount[i] = 0;
bucketLimit[i] = lim;
lim += width;
}
bucketLimit[howManyBuckets-1] = MAXFLOAT; /* from math.h */
}
Histogram::~Histogram()
{
if (howManyBuckets > 0) {
delete bucketCount;
delete bucketLimit;
}
}
void
Histogram::operator+=(double value)
{
int i;
for (i = 0; i < howManyBuckets; i++) {
if (value < bucketLimit[i]) break;
}
bucketCount[i]++;
Statistic::operator+=(value);
}
int
Histogram::similarSamples(double d)
{
int i;
for (i = 0; i < howManyBuckets; i++) {
if (d < bucketLimit[i]) return(bucketCount[i]);
}
return(0);
}
void
Histogram::classPrintOn(ostream& s)
{
Statistic::classPrintOn(s);
s << "\n";
for(int i = 0; i < howManyBuckets; i++) {
s << "< " << bucketLimit[i] << " : " << bucketCount[i] << "\n";
}
}
void
Histogram::printBuckets(ostream& s)
{
for(int i = 0; i < howManyBuckets; i++) {
if (bucketLimit[i] >= MAXFLOAT) {
s << "< max : " << bucketCount[i] << "\n";
} else {
s << "< " << bucketLimit[i] << " : " << bucketCount[i] << "\n";
}
}
}
void
Histogram::reset()
{
Statistic::reset();
if (howManyBuckets > 0) {
for (register int i = 0; i < howManyBuckets; i++) {
bucketCount[i] = 0;
}
}
}
@
3.2
log
@Start using Gnu library heaps for schedulers
@
text
@@
3.1
log
@Steay version
@
text
@@
1.2
log
@*** empty log message ***
@
text
@@
1.1
log
@Initial revision
@
text
@d1 6
@